<?php

declare(strict_types=1);

namespace app\model;

use app\common\model\Goods as payGoods;
use app\common\service\Taototo;
use app\third\controller\Pay;
use think\model\concern\SoftDelete;
use think\facade\Db;

/**
 * 
 *
 * @mixin \think\Model
 * @property int $id 自增id
 * @property int $city_id 城市id
 * @property int $area_id 地区id
 * @property string $name 城市名称
 * @property string $pin_yin 城市首字母
 */
class TaototoCity extends CommonModel
{
    //返回城市给前端选择
    public static function getCity($data)
    {
        $where=[];
        if (!empty($data['city_id'])) {
            $where[]=['city_id','=',$data['city_id']];
            $where[]=['area_id','>',0];
        } else {
            $where[]=['area_id','=',0];
        }
        if (empty($data['city_id']) && !empty($data['city_name'])) {
            $cityName = str_replace('市', '', $data['city_name']);
            $cityId = Db::name('taototo_city')
                    ->where('name', $cityName)
                    ->value('city_id');
            if ($cityId) {
                $where[]=['city_id','=',$cityId];
                $where[]=['area_id','>',0];
            }
        }
        $list=self::where($where)->select()->toArray();
        return $list;
    }
}
